package com.lyjStudy.train.common.context;

import com.lyjStudy.train.common.resp.MemberLoginResp;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class LoginMemberContext {

    private static final Logger LOG = LoggerFactory.getLogger(LoginMemberContext.class);

    private static ThreadLocal<MemberLoginResp> threadLocal = new ThreadLocal<>();

    public static MemberLoginResp getMember(){
        return threadLocal.get();
    }
    public static void setMember(MemberLoginResp resp){
        LoginMemberContext.threadLocal.set(resp);
    }

    public static Long getId(){
        try{
            return threadLocal.get().getId();
        }catch (Exception e){
            LOG.error(e.getMessage());
            throw e;
        }

    }

}
